package org.tloss.web.editor.utils;

import java.util.List;

import org.tloss.web.editor.model.FormField;
import org.tloss.web.editor.model.oper.math.FormFieldOperand;
import org.tloss.web.editor.model.oper.math.MathOperand;

public class FormFieldVariable implements Variable {

	private FormField formField;

	public void setFormField(FormField formField) {
		this.formField = formField;
	}

	public FormField getFormField() {
		return formField;
	}

	private Variable parent;

	public List<Variable> getChildren() {
		return null;
	}

	@Override
	public void setChildren(List<Variable> variables) {

	}

	@Override
	public Variable getParent() {
		return parent;
	}

	@Override
	public void setParent(Variable parent) {
		this.parent = parent;

	}

	@Override
	public boolean hasChildren() {
		return false;
	}

	@Override
	public MathOperand convertToMathOperand() {
		FormFieldOperand operand = new FormFieldOperand();
		operand.setFormField(formField);
		return operand;
	}

	@Override
	public String toString() {
		return formField != null ? (formField.getName() != null ? formField
				.getName() : "") : "";
	}

}
